#ifndef CLOCKMANAGER_H
#define CLOCKMANAGER_H

#include "hub75e.h"
#include "ntpTime.h"

class ClockManager {
public:
    ClockManager(Panel& panel, NTPTime& ntpTime);
    
    // Main update method that combines timing and drawing
    bool updateIfNeeded(unsigned long& lastUpdate, unsigned long intervalMs, int rightTzOffsetHours = -8, bool otaInProgress = false);
    
    // Direct drawing method for manual updates
    void drawClock(int rightTzOffsetHours = -8, bool otaInProgress = false);

private:
    Panel& _panel;
    NTPTime& _ntpTime;
    
    // Internal drawing method for analog clock
    void drawAnalogClock(uint16_t posX, uint16_t posY, uint16_t w, uint16_t h,
                        uint8_t hour, uint8_t minute, uint8_t second,
                        const char* weekDayStr, int year, int month, int day,
                        const char* locationStr);
    
    // Helper methods
    void drawText5x8(const char* text, uint16_t x, uint16_t y, uint8_t r, uint8_t g, uint8_t b);
    void getTimeForTimezone(int tzOffsetHours, uint8_t& hour, uint8_t& minute, uint8_t& second, 
                           uint8_t& wday, int& year, int& month, int& day, const char*& weekDayStr);
    void getFallbackTime(uint8_t& hour, uint8_t& minute, uint8_t& second, 
                        uint8_t& wday, int& year, int& month, int& day, const char*& weekDayStr);
};

#endif // CLOCKMANAGER_H